﻿<%@ CODEPAGE=65001%>
<%
  Response.CodePage=65001
  response.contentType="text/html"
  response.charset="UTF-8"
  response.buffer = true  
  response.CacheControl = "no-cache"
  Server.ScriptTimeOut = 300
%>
<!--#include file="clsUp.asp"-->
<%	
	if session("net_folder_path") = "" then
		response.Write("你没有上传权限")
		response.end
	end if  
	
	dim upfile,formName,oFile,upfilecount, msg, filePath
	upfilecount=0
	set upfile=new clsUp ''建立上传对象
	upfile.NoAllowExt="asp;aspx;php;inc;pl;cgi;jsp;class"	'设置上传类型的黑名单
	upfile.GetData (2 * 1024^2)   '取得上传数据,限制最大上传2M
	
	if upfile.isErr then  '如果出错
		select case upfile.isErr
		case 1
			set upfile=nothing
			msg = "你没有上传数据呀???是不是搞错了??"
		case 2
			set upfile=nothing
			msg = "你上传的文件超出我们的限制,最大2M。"
		end select
	else
		for each formName in upfile.file '列出所有上传了的文件
		   set oFile = upfile.file(formName)
		   filePath = session("net_folder_path") & "/" &oFile.filename
		   upfile.SaveToFile formName, Server.mapPath(filePath)   ''保存文件 也可以使用AutoSave来保存,参数一样,但是会自动建立新的文件名
		   if upfile.iserr then 
				msg = upfile.errmessage
		   else
				upfilecount=upfilecount+1
		   end if
		 set oFile=nothing
		next
	end if
	set upfile=nothing  '删除此对象
	'response.write upfilecount
	if msg <>"" then
		response.Write(msg & "<a href='#' onclick='javascript:window.histroy.back()'>后退</a>")
		response.end
	else
		if request.QueryString("actionid") = "uploadimage" then
			response.Write("<body topmargin=0 leftmargin=0>上传成功。</body>")
%>
	<script language=javascript>
	parent.document.getElementById("urlValue").value="<%="http://" & Request.ServerVariables("SERVER_NAME") & filePath%>";
	</script>
<%			
		else

			response.redirect "index.asp?folder=" & server.URLEncode(request.queryString("folder"))
		end if
	end if
%>
